<template>
	<div id="app">
		<img alt="Vue logo" src="./assets/logo.png" />
		<HelloWorld msg="Welcome to Your Vue.js App" />
	</div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
	name: 'App',
	components: {
		HelloWorld,
	},
	created() {
		this.fn()
	},
	methods: {
		fetchVehicle() {
			return new Promise((resolve, reject) => {
				resolve({
					data: {
						code: 200,
						msg: '成功啦',
					},
				})
				reject('我是错误的消息')
			})
		},

		async fn() {
			// 每个异步都需要处理
			const [err, { data }] = await this.to(this.fetchVehicle())
			console.log('err', err)
			console.log('data', data)
		},
	},
}
</script>

<style>
#app {
	font-family: Avenir, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-align: center;
	color: #2c3e50;
	margin-top: 60px;
}
</style>
